package com.raccoonagents.tools.cascet2d.model.components;

import com.raccoonagents.tools.cascet2d.interfaces.rendering.IMaskedTexturedRenderable;
import com.raccoonagents.tools.cascet2d.model.Vector2f;
import com.raccoonagents.tools.cascet2d.util.GraphicUtil;

public class ImageComponent extends AbstractStageComponent implements IMaskedTexturedRenderable{

	protected Integer image = null;
	protected Integer mask = null;
	protected float [] color = new float []{1.0f,1.0f,1.0f};
	protected float opacity = 1.0f;
	protected Vector2f pivot = new Vector2f(0.0f,0.0f);
	public void setOpacity(final float opacity) {
		this.opacity = opacity;
	}

	public ImageComponent(final Vector2f size, final Vector2f location, final int image){
		this.size = size;
		this.localLocation = location;
		this.image = image;
	}
	
	public void setMask(final int mask){
		this.mask = mask;
	}
	
	public void setImage(final int image){
		this.image = image;
	}
	
	@Override
	public void render() {
		if(!visible){
			return;
		}
		
		if(mask == null){
			GraphicUtil.renderImage(this);			
		}else{
			GraphicUtil.renderMaskedImage(this);						
		}
		
	}

	@Override
	public int getMaskImage() {
		return mask;
	}

	@Override
	public int getTexture() {
		return image;
	}

	@Override
	public float[] getColor() {
		return color;
	}

	@Override
	public float getOpacity() {
		return opacity;
	}


	@Override
	public float getRotation() {
		return 0;
	}

	@Override
	public Vector2f getPivot() {
		return pivot;
	}

}
